/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.subway.persistencias;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Héctor <UFG>
 */
@Entity
@Table(name = "cat_documento", catalog = "bd_subway", schema = "", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"docPropietarioId"})})
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CatDocumento.findAll", query = "SELECT c FROM CatDocumento c"),
    @NamedQuery(name = "CatDocumento.findByDocId", query = "SELECT c FROM CatDocumento c WHERE c.docId = :docId"),
    @NamedQuery(name = "CatDocumento.findByDocTipo", query = "SELECT c FROM CatDocumento c WHERE c.docTipo = :docTipo"),
    @NamedQuery(name = "CatDocumento.findByDocNumero", query = "SELECT c FROM CatDocumento c WHERE c.docNumero = :docNumero")})
public class CatDocumento implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "docId")
    private Integer docId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 40)
    @Column(name = "docTipo", nullable = false, length = 40)
    private String docTipo;
    @Basic(optional = false)
    @NotNull
    @Column(name = "docNumero", nullable = false)
    private int docNumero;
    @JoinColumn(name = "docPropietarioId", referencedColumnName = "personaId", nullable = false)
    @OneToOne(optional = false)
    private Persona docPropietarioId;

    public CatDocumento() {
    }

    public CatDocumento(Integer docId) {
        this.docId = docId;
    }

    public CatDocumento(Integer docId, String docTipo, int docNumero) {
        this.docId = docId;
        this.docTipo = docTipo;
        this.docNumero = docNumero;
    }

    public Integer getDocId() {
        return docId;
    }

    public void setDocId(Integer docId) {
        this.docId = docId;
    }

    public String getDocTipo() {
        return docTipo;
    }

    public void setDocTipo(String docTipo) {
        this.docTipo = docTipo;
    }

    public int getDocNumero() {
        return docNumero;
    }

    public void setDocNumero(int docNumero) {
        this.docNumero = docNumero;
    }

    public Persona getDocPropietarioId() {
        return docPropietarioId;
    }

    public void setDocPropietarioId(Persona docPropietarioId) {
        this.docPropietarioId = docPropietarioId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (docId != null ? docId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CatDocumento)) {
            return false;
        }
        CatDocumento other = (CatDocumento) object;
        if ((this.docId == null && other.docId != null) || (this.docId != null && !this.docId.equals(other.docId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.docTipo + " " + this.docNumero;
    }
    
}
